﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Linq;

namespace spike
{
    public class ViewModel
    {
        public DataTable DataTable
        {
            get { var dt = new DataTable();
                foreach (var h in Header)
                    dt.Columns.Add(h);

                foreach (var zeile in Data)
                {
                    var row = dt.NewRow();
                    for (int i = 0; i < zeile.Count(); i++)
                    {
                        row[i] = zeile.ElementAt(i);
                    }
                    dt.Rows.Add(row);
                }
                return dt;
            }
        }

        public ObservableCollection<string> Header { get; set; }
        public ObservableCollection<IEnumerable<string>> Data { get; set; }

        public ViewModel()
        {
            Header = new ObservableCollection<string>(new[] {"A", "B"});
            Data = new ObservableCollection<IEnumerable<string>>(new[] { new []{"a", "b"} });
        }
    }
}